package com.mxchip.livestar.ui.call

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.mxchip.livestar.R
import com.mxchip.livestar.ui.Call
import com.videohigh.graham.SessionContext

class StartFragment : Fragment() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_start, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        (activity?.intent?.getSerializableExtra(CallConst.CALL_POJO) as Call?)?.let {
            val directions = StartFragmentDirections.actionStartFragmentToGreenFragment(it)
            findNavController().navigate(directions)
            return
        }

        (activity?.intent?.getSerializableExtra(CallConst.NOTIFY_INFO) as SessionContext?)?.let {
            val directions = StartFragmentDirections.actionStartFragmentToRedFragment(it)
            findNavController().navigate(directions)
            return
        }
    }

    companion object {
    }
}
